/* GUI CONVERTED from reintchk.p (converter v1.75) Tue Jun  5 16:00:26 2001 */
/* reintchk.p - REPETITIVE                                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8 $                                                           */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.8 $    BY: Hualin Zhong  DATE: 05/30/01 ECO: *N0YY*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* SUBPROGRAM TO CHECK CUM ORDER INTEGRITY - USED FOR TESTING PURPOSES
(OUTPUT QUEUE + REJECT QUEUE + INPUT QUEUE(NEXT OP).  INPUT QUEUE OF
THE next OP is INCLUDED BECAUSE IT is VALUED at THE COST of THIS OP.
*/

{mfdeclre.i}

define input parameter cumwo_lot as character.

define variable glx_mthd like cs_method.
define variable glx_set like cs_set.
define variable cur_mthd like cs_method.
define variable cur_set like cs_set.
define variable total_unaveraged as decimal.
define variable total_wip_cost as decimal.
define variable last_op_cost as decimal.

leave.

find wo_mstr where wo_lot = cumwo_lot no-lock.

/*DETERMINE COSTING METHOD*/
{gprun.i ""csavg01.p"" "(input  wo_part,
                         input  wo_site,
                         output glx_set,
                         output glx_mthd,
                         output cur_set,
                         output cur_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/*CHECK INTEGRITY OF AVERAGE COSTING ACCUMS*/
if glx_mthd = "AVG" then do:
   for each wr_route no-lock
   where wr_lot = cumwo_lot.

   assign
      total_wip_cost = total_wip_cost
                     + wr_lbr_act
                     + wr_bdn_act
                     + wr_sub_act
                     + wr_mtl_act
      total_wip_cost = total_wip_cost
                     + wr_lbr_ll_act
                     + wr_bdn_ll_act
                     + wr_sub_ll_act
                     + wr_mtl_ll_act
      total_wip_cost = total_wip_cost
                     - wr_lbr_totx
                     - wr_bdn_totx
                     - wr_sub_totx
                     - wr_mtl_totx
      total_wip_cost = total_wip_cost
                     - wr_lbr_ll_totx
                     - wr_bdn_ll_totx
                     - wr_sub_ll_totx
                     - wr_mtl_ll_totx.
   end.

   if total_wip_cost - wo_wip_tot > .001
      or total_wip_cost - wo_wip_tot < - .001
   then do:
      /* LOSS OF AVERAGE COST INTEGRITY */
      {pxmsg.i &MSGNUM=4653
               &ERRORLEVEL=1
               &MSGARG1=total_wip_cost
               &MSGARG2=wo_wip_tot}
      bell.
      pause.
   end.
   else do:
      /* AVERAGE COSTING OK */
      {pxmsg.i &MSGNUM=4652 &ERRORLEVEL=1}
      pause.
   end.
end.
